package io.renren.modules.work.controller;

import io.renren.common.utils.R;
import io.renren.modules.sys.controller.AbstractController;
import io.renren.modules.work.entity.WorkEntity;
import io.renren.modules.work.service.WorkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author: weihongyang
 * @Date: 2019/10/14 9:59
 * @Version 1.0
 */
@RestController
@Api(description = "出库任务")
@RequestMapping("/work/controller")
public class WorkController extends AbstractController {

    @Autowired
    private WorkService workService;

    @ApiOperation(value = "手动下总任务" , notes = "手动下总任务")
    @PostMapping("/check/out/for/main/task")
    public R checkOutForMainTask(@RequestBody Map<String, Object> params){

        params.put("userId",getUserId());
        params.put("userName",getUser().getUsername());
        workService.checkOutForMainTask(params);
        return R.ok();
    }

    @ApiOperation(value = "出库总任务下发" , notes = "出库总任务下发")
    @PostMapping("/check/out/main/task/for/det")
    public R checkOutMainTaskForDet(@RequestBody Map<String, Object> params){

        params.put("doorWay",getUser().getDoorWay());
        return workService.checkOutMainTaskForDet(params);
    }

    @ApiOperation(value = "出库子任务执行" , notes = "出库子任务执行")
    @PostMapping("/execute/issue/task")
    public R executeIssueTask(@RequestBody Map<String, Object> params){

        workService.executeIssueTask(params);

        return R.ok();
    }

    @ApiOperation(value = "测试" , notes = "测试")
    @PostMapping("/test")
    public R test(@RequestBody WorkEntity workEntity){

        return R.ok();
    }

}
